package com.ruoyi.zhjd.laboratory.modules.errorRecord.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.zhjd.laboratory.modules.errorRecord.entity.ErrorRecordEntity;
import com.ruoyi.zhjd.laboratory.modules.errorRecord.service.ErrorRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;

/**
 * 试验错误数据结果记录
 *
 * @author sx
 * @email
 * @date 2023-07-12 17:15:06
 */
@RestController
@RequestMapping("laboratory/errorRecord")
public class ErrorRecordController {

    @Autowired
    private ErrorRecordService errorRecordService;

    /**
     * 列表
     */
    @RequestMapping("/page")
    //
    public R page(@RequestParam Map<String, Object> params){
        IPage page = errorRecordService.queryPage(params);
        return R.ok(page);
    }


    /**
     * 信息
     */
    @RequestMapping("/find/{id}")
    //
    public R find(@PathVariable("id") String id){
		ErrorRecordEntity errorRecord = errorRecordService.getInfo(id);
        return R.ok(errorRecord);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //
    public R save(@RequestBody ErrorRecordEntity errorRecord){
		errorRecordService.saveData(errorRecord);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //
    public R update(@RequestBody ErrorRecordEntity errorRecord){
        errorRecordService.updateData(errorRecord);
        return R.ok();
    }


    /**
     * 删除单个
     */
    @RequestMapping("/delete/{id}")
    //
    public R deleteOne(@PathVariable("id") String id){
        errorRecordService.deleteOneData(id);
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")

    public R delete(@RequestBody String[] ids){
        errorRecordService.deleteData(Arrays.asList(ids));
        return R.ok();
    }
}
